<script>
import Identity from '../../../config/Identity';
const api = window.$api.organization.user

import { mapGetters } from "vuex"
export default {
  data() {
    return {

    }
  },
  computed: {
    ...mapGetters(["tagWel","appConfig"]),
    oauth() {
      return Identity.oauth2
    },
    code() {
      return this.$route.query.code
    }
  },
  mounted() {
    //授权码模式
    if(this.oauth.response_type == 'code'){
      api.loginByIdentityCode(this.code).then(res => {
        const data = res.data.data
        this.$store.commit('organization/user/SET_TOKEN', data.token)
        this.$store.commit('organization/user/DEL_ALL_TAG','',{ root: true })
        this.$store.commit('app/SET_ISFIRSTLOAD',true)
        this.$router.push({ path: this.tagWel.value })
      }).catch((data) => {
        console.log("api.loginByIdentityCode ~ data:", data)
        console.error("该用户未同步")
      })
    }
  }
}
</script>

<style scoped lang='scss'>
</style>